package com.sky.controller;

import com.sky.anotion.validator.UpdateGroup;
import com.sky.constant.MessageConstant;
import com.sky.dto.common.QueryParams;
import com.sky.entity.LogicFlow;
import com.sky.result.Result;
import com.sky.service.LogicFlowControllerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/api/logicFlow")
public class LogicFlowController {
    @Autowired
    private LogicFlowControllerService logicFlowControllerService;

    /**
     * 增加编排流程
     * @param logicFlow
     * @return
     */
    @PostMapping("/add")
    public Result<String> add (@RequestBody LogicFlow logicFlow){
        logicFlowControllerService.add(logicFlow);
        return Result.success(null,MessageConstant.OK_MESSAGE);
    }

    /**
     * 修改编排流程
     * @param logicFlow
     * @return
     */
    @PostMapping("/update")
    public Result<String> update(@RequestBody  LogicFlow logicFlow) {
        logicFlowControllerService.update(logicFlow);
        return Result.success(null, MessageConstant.OK_MESSAGE);
    }

    /**
     * 获取编排流程
     * @param queryParams
     * @return
     */
    @PostMapping("/get")
    public Result<LogicFlow> get(@RequestBody QueryParams queryParams) {
        LogicFlow logicFlow = logicFlowControllerService.get(queryParams.getId());
        return Result.success(logicFlow, MessageConstant.OK_MESSAGE);
    }
}
